package com.etc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.etc.dao.MedicineMapper;
import com.etc.entity.Medicine;
import com.etc.service.MedicineService;
import com.github.pagehelper.PageInfo;

@Service(value="MedicineService")
public class MedicineServiceImpl implements MedicineService {

	@Autowired
	private MedicineMapper medicineMapper;
	@Override
	public List<Medicine> selectMedicineByPage(int pageStar,int pageSize) {
		return medicineMapper.selectMedicineByPage(pageStar,pageSize);
	}

	@Override
	public boolean insertMedicine(Medicine medicine) {
		// TODO Auto-generated method stub
		return medicineMapper.insert(medicine)>0;
	}
	
	@Override
	public boolean updMedicine(Medicine medicine) {
		// TODO Auto-generated method stub
		return medicineMapper.updateByPrimaryKey(medicine)>0;
	}
	
	@Override
	public boolean delMedicine(Integer medicineid) {
		// TODO Auto-generated method stub
		return medicineMapper.deleteByPrimaryKey(medicineid)>0;
	}
	
	/*@Override
	public List<Medicine> getMedicineByPageAndLike(int start, int pageSize, String keywords) {
		// TODO Auto-generated method stub
		return medicineMapper.getMedicineByPageAndLike(start, pageSize, keywords);
	}
	*/
	@Override
	public Medicine selectMedicineById(Integer medicineid) {
		// TODO Auto-generated method stub
		return medicineMapper.selectByPrimaryKey(medicineid);
	}
	
	@Override
	public int selCountMedicine() {
		// TODO Auto-generated method stub
		return medicineMapper.selCountMedicine();
	}
	
	/**
	 * 查询所有药品类型
	 */
	@Override
	public List<Medicine> selMedicineType() {
		// TODO Auto-generated method stub
		return medicineMapper.selMedicineType();
	}
	/**
	 * 根据药品类型查询所有药品
	 */
	@Override
	public List<Medicine> selMedicineByType(String medicineType) {
		// TODO Auto-generated method stub
		return medicineMapper.selMedicineByType(medicineType);
	}
	/**
	 * 根据药品名称查询药品Id
	 */
	@Override
	public int selMedicineIdByName(String medicineName) {
		// TODO Auto-generated method stub
		return medicineMapper.selMedicineIdByName(medicineName);
	}

}
